package com.tsd.jxc.stock;

import com.tsd.core.utils.HlpUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: StockConstants
 * @Description: TODO
 * @Author: Hillpool
 * @Date: 2022/8/1 18:20
 * @Version: 1.0
 */
public class StockConstants {

    /**
     * 审核状态：0-未审核、1-已审核
     */
    public static final int STATE_UN_AUDIT = 0;
    public static final int STATE_AUDITED = 1;

    /**
     * 层级：building-栋、floor-层、unit-单元、row-行、chequer-格子
     */
    public final static String LEVEL_BUILDING = "building";
    public final static String LEVEL_FLOOR = "floor";
    public final static String LEVEL_UNIT = "unit";
    public final static String LEVEL_ROW = "row";
    public final static String LEVEL_CHEQUER = "chequer";

    /**
     * 记录增加类型，single-单个增加，bat-批量增加，imp-导入，api-api调用增加
     */
    public final static String ADD_TYPE_SINGLE = "single";
    public final static String ADD_TYPE_BAT = "bat";
    public final static String ADD_TYPE_IMP = "imp";
    public final static String ADD_TYPE_API = "api";


    // 是否生成了入/出库单，0-否，1-部分生成，2-全部生成
    public static final Integer IN_OUT_BILL_NO = 0;
    public static final Integer IN_OUT_BILL_PART = 1;
    public static final Integer IN_OUT_BILL_ALL = 2;

    // 生成入库单标志，0-全部未生成，1-部分已生成,2-全部已生成
    public static final Integer DETAIL_IN_OUT_BILL_NONE = 0;
    public static final Integer DETAIL_IN_OUT_BILL_PART = 1;
    public static final Integer DETAIL_IN_OUT_BILL_ALL = 2;


    public static final String OUT_TYPE_SALE = "sale_out";
    public static final String NAME_OUT_TYPE_SALE = "销售出库";

    public static final String OUT_TYPE_BUY_RETURN = "buy_return_out";
    public static final String NAME_OUT_TYPE_BUY_RETURN = "采购退货";

    public static final String OUT_TYPE_PRODUCTION = "production_out";
    public static final String NAME_OUT_TYPE_PRODUCTION = "领料出库";

    public static final String OUT_TYPE_ALLOCATION = "allocation_out";
    public static final String NAME_OUT_TYPE_ALLOCATION = "调拨出库";

    public static final String OUT_TYPE_LOSS = "loss_out";
    public static final String NAME_OUT_TYPE_LOSS = "盘亏出库";

    public static final String IN_TYPE_BUY = "buy_in";
    public static final String NAME_IN_TYPE_BUY = "采购入库";

    public static final String IN_TYPE_SALE_RETURN = "sale_return_in";
    public static final String NAME_IN_TYPE_SALE_RETURN = "销售退货";

    public static final String IN_TYPE_ALLOCATION = "allocation_in";
    public static final String NAME_IN_TYPE_ALLOCATION = "调拨入库";

    public static final String IN_TYPE_PRODUCTION = "production_in";
    public static final String NAME_IN_TYPE_PRODUCTION = "生产入库";

    public static final String IN_TYPE_SURPLUS = "surplus_in";
    public static final String NAME_IN_TYPE_SURPLUS = "盘盈入库";

    public static final String OPERATE_ADD = "add";
    public static final String OPERATE_SUB = "sub";

    public static final String BIZ_NAME_IN_BILL = "jxc_stock_inbill";
    public static final String BIZ_NAME_OUT_BILL = "jxc_stock_outbill";
    public static final String BIZ_NAME_INVENTORY = "jxc_stock_inventory";
    //付款类型，采购、销售
    public static final String PAY_TYPE_FOR_BUY = "buy";
    public static final String PAY_TYPE_FOR_SALE = "sale";

    /**
     * 是否已经更新库存，0-否，1-是
     */
    public static final Integer UPDATE_STOCK = 1;
    public static final Integer UN_UPDATE_STOCK = 0;

    /**
     * 出入库清单类型：in-入库、out-出库
     */
    public static final String TYPE_IN = "in";
    public static final String TYPE_OUT = "out";

    private static final Map<String, String> OUT_TYPE_MAP;
    private static final Map<String, String> IN_TYPE_MAP;
    private static final Map<String, String> LEVEL_MAP;

    static {
        OUT_TYPE_MAP = new HashMap<>();
        OUT_TYPE_MAP.put(OUT_TYPE_SALE, NAME_OUT_TYPE_SALE);
        OUT_TYPE_MAP.put(OUT_TYPE_BUY_RETURN, NAME_OUT_TYPE_BUY_RETURN);
        OUT_TYPE_MAP.put(OUT_TYPE_ALLOCATION, NAME_OUT_TYPE_ALLOCATION);
        OUT_TYPE_MAP.put(OUT_TYPE_PRODUCTION, NAME_OUT_TYPE_PRODUCTION);
        OUT_TYPE_MAP.put(OUT_TYPE_LOSS, NAME_OUT_TYPE_LOSS);

        IN_TYPE_MAP = new HashMap<>();
        IN_TYPE_MAP.put(IN_TYPE_BUY, NAME_IN_TYPE_BUY);
        IN_TYPE_MAP.put(IN_TYPE_SALE_RETURN, NAME_IN_TYPE_SALE_RETURN);
        IN_TYPE_MAP.put(IN_TYPE_ALLOCATION, NAME_IN_TYPE_ALLOCATION);
        IN_TYPE_MAP.put(IN_TYPE_PRODUCTION, NAME_IN_TYPE_PRODUCTION);
        IN_TYPE_MAP.put(IN_TYPE_SURPLUS, NAME_IN_TYPE_SURPLUS);

        LEVEL_MAP = new HashMap<>();
        LEVEL_MAP.put(LEVEL_BUILDING, "栋");
        LEVEL_MAP.put(LEVEL_FLOOR, "层");
        LEVEL_MAP.put(LEVEL_UNIT, "单元");
        LEVEL_MAP.put(LEVEL_ROW, "行");
        LEVEL_MAP.put(LEVEL_CHEQUER, "格子");
    }

    public String getOutTypeName(String out_type) {
        if (!HlpUtils.isEmpty(out_type)) {
            return OUT_TYPE_MAP.get(out_type);
        }
        return null;
    }

    public String getInTypeName(String in_type) {
        if (!HlpUtils.isEmpty(in_type)) {
            return IN_TYPE_MAP.get(in_type);
        }
        return null;
    }

    public static String getLevelName(String level) {
        if (!HlpUtils.isEmpty(level)) {
            return LEVEL_MAP.get(level);
        }
        return null;
    }
}
